import pytest
import sqlite3


@pytest.fixture()
def dbconnection():
    connection = sqlite3.connect("funds.db")
    print("数据库连接成功")
    yield connection
    connection.close()
    print("数据库连接已关闭")


def test_case1(dbconnection):
    cursor1 = dbconnection.cursor()
    sql = "select count(1) from fund;"
    cursor1.execute(sql)
    result = cursor1.fetchone()[0]
    assert result == 11201

if __name__ == '__main__':
    pytest.main(['-s', 'mengfeiyuan.py'])